<?php

/**
 * 主题选项
 * @author Seaton Jiang <hi@seatonjiang.com>
 * @license GPL-3.0 License
 * @version 2025.02.08
 */

defined('ABSPATH') || exit;

$prefix = 'wanzi_options';

if (!function_exists('wanzi_option')) {
    function wanzi_option($name, $default = false)
    {

        $options = get_option('wanzi_options');

        if (isset($options[$name])) {
            return $options[$name];
        }

        return $default;
    }
}

function getrobots()
{
    $site_url = parse_url(site_url());
    $web_url = get_bloginfo('url');
    $path = (!empty($site_url['path'])) ? $site_url['path'] : '';

    $robots = "User-agent: *\n\n";
    $robots .= "Disallow: $path/wp-admin/\n";
    $robots .= "Disallow: $path/wp-includes/\n";
    $robots .= "Disallow: $path/wp-content/plugins/\n";
    $robots .= "Disallow: $path/wp-content/themes/\n\n";
    $robots .= "Sitemap: $web_url/wp-sitemap.xml\n";

    return $robots;
}

CSF::createOptions($prefix, array(
    'menu_title' => __('主题设置', 'wanzi'),
    'menu_slug' => 'wanzi-options',
    'show_search' => false,
    'show_all_options' => false,
    'sticky_header' => false,
    'admin_bar_menu_icon' => 'dashicons-admin-generic',
    'framework_title' => '主题设置<small style="margin-left:10px">wanzi v' . THEME_VERSION . '</small>',
    'theme' => 'light',
    'footer_credit' => '感谢使用 <a target="_blank" href="https://aihack.cn">丸子</a> 主题进行创作，添加客服微信加入交流群：<a target="_blank">hackdxd</a>',
));

CSF::createSection($prefix, array(
    'id' => 'global_fields',
    'title' => __('全站配置', 'wanzi'),
    'icon' => 'fas fa-rocket',
));

CSF::createSection($prefix, array(
    'parent' => 'global_fields',
    'title' => __('功能配置', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'id' => 'g_classic_editor_switch',
            'type' => 'switcher',
            'title' => __('经典编辑器', 'wanzi'),
            'subtitle' => __('开启后，将禁用古腾堡编辑器并启用经典编辑器。', 'wanzi'),
            'default' => false,
        ),
        array(
            'id' => 'g_replace_gravatar_url_fieldset',
            'type' => 'fieldset',
            'fields' => array(
                array(
                    'type' => 'subheading',
                    'content' => __('Gravatar 加速服务', 'wanzi'),
                ),
                array(
                    'id' => 'g_replace_gravatar_url',
                    'type' => 'switcher',
                    'title' => __('功能开关', 'wanzi'),
                    'subtitle' => __('开启/关闭 Gravatar 加速服务功能', 'wanzi'),
                ),
                array(
                    'id' => 'g_select_gravatar_server',
                    'type' => 'select',
                    'title' => __('Gravatar 加速服务地址', 'wanzi'),
                    'subtitle' => __('请选择 Gravatar 加速服务地址', 'wanzi'),
                    'options' => array(
                        'loli' => __('Loli 加速服务', 'wanzi'),
                        'geekzu' => __('极客族加速服务', 'wanzi'),
                        'other' => __('自定义加速服务', 'wanzi'),
                    ),
                    'desc' => __('国内用户推荐「极客族加速服务」，海外用户推荐「Loli 加速服务」。', 'wanzi'),
                    'dependency' => array('g_replace_gravatar_url', '==', 'true'),
                ),
                array(
                    'id' => 'g_custom_gravatar_server',
                    'type' => 'text',
                    'title' => __('自定义 Gravatar 加速服务地址', 'wanzi'),
                    'subtitle' => __('请输入 Gravatar 加速服务地址', 'wanzi'),
                    'desc' => __('直接输入网址即可，不需要协议头和最后的斜杠。', 'wanzi'),
                    'placeholder' => 'secure.gravatar.com',
                    'dependency' => array('g_replace_gravatar_url|g_select_gravatar_server', '==|==', 'true|other'),
                ),
            ),
            'default' => array(
                'g_replace_gravatar_url' => 1,
                'g_select_gravatar_server' => 'geekzu',
            )
        ),
        array(
            'id'    => 'g_post_list_style',
            'type'  => 'select',
            'title' => __('文章列表显示模式', 'wanzi'),
            'subtitle' => __('选择在首页和归档页面上显示文章列表的样式。', 'wanzi'),
            'options' => array(
                'grid' => __('网格模式', 'wanzi'),
                'list' => __('列表模式', 'wanzi'),
                'card' => __('卡片模式', 'wanzi'),
            ),
            'default' => 'grid'
        ),
    ),
));


CSF::createSection($prefix, array(
    'parent' => 'global_fields',
    'title' => __('图片配置', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'id' => 'g_logo',
            'type' => 'upload',
            'title' => __('站点 Logo', 'wanzi'),
            'library' => 'image',
            'preview' => true,
            'subtitle' => __('不上传图片则显示站点标题', 'wanzi'),
        ),
        array(
            'id' => 'g_icon',
            'type' => 'upload',
            'title' =>  __('Favicon 图标', 'wanzi'),
            'library' => 'image',
            'preview' => true,
            'subtitle' => __('浏览器收藏夹和地址栏中显示的图标', 'wanzi'),
        ),
        array(
            'id' => 'g_postthumbnail',
            'type' => 'upload',
            'title' =>  __('默认特色图', 'wanzi'),
            'library' => 'image',
            'preview' => true,
            'default' => get_template_directory_uri() . '/assets/img/default.jpg',
            'subtitle' => __('当文章中没有图片且没有特色图时显示', 'wanzi'),
        ),
    ),
));

CSF::createSection($prefix, array(
    'parent' => 'global_fields',
    'title' => __('轮播图配置', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'id' => 'g_carousel',
            'type' => 'switcher',
            'title' => __('功能开关', 'wanzi'),
            'subtitle' => __('开启/关闭首页轮播功能', 'wanzi'),
            'text_on' => __('开启', 'wanzi'),
            'text_off' => __('关闭', 'wanzi'),
            'default' => false,
        ),
        array(
            'id' => 'carousel_group',
            'type' => 'group',
            'title' => '首页轮播',
            'subtitle' => '点击添加轮播内容，最多添加 7 个轮播内容',
            'min' => 1,
            'max' => 7,
            'fields' => array(
                array(
                    'id' => 'c_id',
                    'type' => 'text',
                    'title' =>  __('唯一标识', 'wanzi'),
                    'subtitle' =>  __('仅用于轮播标识，可以作为备注使用', 'wanzi'),
                ),
                array(
                    'id' => 'c_img',
                    'type' => 'upload',
                    'title' => __('轮播图片', 'wanzi'),
                    'subtitle' =>  __('可以直接填写图片链接，也可以上传图片', 'wanzi'),
                    'library' => 'image',
                    'preview' => true,
                ),
                array(
                    'id' => 'c_url',
                    'type' => 'text',
                    'title' =>  __('网址链接', 'wanzi'),
                    'subtitle' =>  __('需要填写完整的链接地址，包含协议头', 'wanzi'),
                ),
                array(
                    'id' => 'c_title',
                    'type' => 'text',
                    'title' =>  __('轮播标题', 'wanzi'),
                    'subtitle' =>  __('选填项目，如果不填则不显示', 'wanzi'),
                ),
                array(
                    'id' => 'c_subtitle',
                    'type' => 'textarea',
                    'title' =>  __('轮播简介', 'wanzi'),
                    'subtitle' =>  __('选填项目，如果不填则不显示', 'wanzi'),
                ),
                array(
                    'id' => 'c_color',
                    'type' => 'color',
                    'default' => '#000',
                    'title' =>  __('文字颜色', 'wanzi'),
                    'subtitle' => __('轮播标题和简介的颜色', 'wanzi'),
                ),
            ),
        ),
    )
));

CSF::createSection($prefix, array(
    'parent' => 'global_fields',
    'title' => __('AI 配置', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'id' => 'ai_enable',
            'type' => 'switcher',
            'title' => __('AI 功能', 'wanzi'),
            'subtitle' => __('开启后，在文章编辑页面标题栏右侧显示生成按钮。', 'wanzi'),
            'default' => false,
        ),
        array(
            'id' => 'ai_provider',
            'type' => 'select',
            'title' => __('AI 服务商', 'wanzi'),
            'subtitle' => __('请选择 AI 服务商', 'wanzi'),
            'options' => array(
                'coze' => __('Coze', 'wanzi'),
                'deepseek' => __('DeepSeek', 'wanzi'),
            ),
            'default' => 'coze',
            'dependency' => array('ai_enable', '==', 'true'),
        ),
        array(
            'id' => 'ai_coze_api_key',
            'type' => 'text',
            'title' => __('Coze Personal Access Token', 'wanzi'),
            'subtitle' => __('请输入您的 Coze Personal Access Token', 'wanzi'),
            'desc' => __('请前往 Coze 官方网站，在个人设置中创建 API 令牌。', 'wanzi'),
            'dependency' => array('ai_enable|ai_provider', '==|==', 'true|coze'),
        ),
        array(
            'id' => 'ai_coze_bot_id',
            'type' => 'text',
            'title' => __('Coze Bot ID', 'wanzi'),
            'subtitle' => __('请输入您要使用的 Bot ID', 'wanzi'),
            'desc' => __('在 Coze 平台的机器人发布页面可以找到 Bot ID。', 'wanzi'),
            'dependency' => array('ai_enable|ai_provider', '==|==', 'true|coze'),
        ),
        array(
            'id' => 'ai_coze_api_base',
            'type' => 'select',
            'title' => __('Coze API 地域', 'wanzi'),
            'subtitle' => __('请选择 Coze API 服务所在的区域', 'wanzi'),
            'options' => array(
                'com' => __('国际', 'wanzi'),
                'cn' => __('中国', 'wanzi'),
            ),
            'default' => 'com',
            'dependency' => array('ai_enable|ai_provider', '==|==', 'true|coze'),
        ),
        array(
            'id' => 'ai_deepseek_api_key',
            'type' => 'text',
            'title' => __('DeepSeek API Key', 'wanzi'),
            'subtitle' => __('请输入您的 DeepSeek API Key', 'wanzi'),
            'desc' => __('请前往 DeepSeek 开放平台，在 API 密钥管理页面创建 API Key。', 'wanzi'),
            'dependency' => array('ai_enable|ai_provider', '==|==', 'true|deepseek'),
        ),
    )
));

CSF::createSection($prefix, array(
    'parent' => 'global_fields',
    'title' => __('第三方配置', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'type' => 'notice',
            'style' => 'info',
            'content' => '提示：<strong>DogeCloud 云存储</strong> 与 <strong>火山引擎 ImageX</strong>请勿同时开启！',
        ),
        array(
            'id' => 'g_cos_fieldset',
            'type' => 'fieldset',
            'fields' => array(
                array(
                    'type' => 'subheading',
                    'content' => __('DogeCloud 云存储', 'wanzi'),
                ),
                array(
                    'type' => 'submessage',
                    'style' => 'info',
                    'content' => 'DogeCloud 云存储提供<strong> 10 GB </strong>的免费存储额度，<strong> 20 GB </strong>每月的免费 CDN 额度，<a target="_blank" href="https://console.dogecloud.com/register.html?iuid=614">立即注册</a>',
                ),
                array(
                    'id' => 'g_cos',
                    'type' => 'switcher',
                    'title' => __('功能开关', 'wanzi'),
                    'subtitle' => __('开启/关闭 DogeCloud 云存储', 'wanzi'),
                    'text_on' => __('开启', 'wanzi'),
                    'text_off' => __('关闭', 'wanzi'),
                ),
                array(
                    'id' => 'g_cos_bucketname',
                    'type' => 'text',
                    'title' => __('空间名称', 'wanzi'),
                    'subtitle' => __('空间名称可在空间基本信息中查看', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.dogecloud.com/oss/list">点击这里</a>查询空间名称', 'wanzi'),
                ),
                array(
                    'id' => 'g_cos_url',
                    'type' => 'text',
                    'title' => __('加速域名', 'wanzi'),
                    'subtitle' => __('域名结尾不要添加 /', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.dogecloud.com/oss/list">点击这里</a>查询加速域名', 'wanzi'),
                ),
                array(
                    'id' => 'g_cos_accesskey',
                    'type' => 'text',
                    'title' => __('AccessKey', 'wanzi'),
                    'subtitle' => __('出于安全考虑，建议周期性地更换密钥', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.dogecloud.com/user/keys">点击这里</a>查询 AccessKey', 'wanzi'),
                ),
                array(
                    'id' => 'g_cos_secretkey',
                    'type' => 'text',
                    'attributes' => array(
                        'type' => 'password',
                    ),
                    'title' => __('SecretKey', 'wanzi'),
                    'subtitle' => __('出于安全考虑，建议周期性地更换密钥', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.dogecloud.com/user/keys">点击这里</a>查询 SecretKey', 'wanzi'),
                ),
            ),
            'default' => array(
                'g_cos' => false,
                'g_cos_bucketname' => '',
                'g_cos_url' => '',
                'g_cos_accesskey' => '',
                'g_cos_secretkey' => '',
            ),
        ),
        array(
            'id' => 'g_imgx_fieldset',
            'type' => 'fieldset',
            'fields' => array(
                array(
                    'type' => 'subheading',
                    'content' => __('火山引擎 ImageX', 'wanzi'),
                ),
                array(
                    'type' => 'submessage',
                    'style' => 'info',
                    'content' => '火山引擎 ImageX 提供<strong> 10 GB </strong>的免费存储额度，<strong> 10 GB </strong>每月的免费 CDN 额度，<strong> 20 TB </strong>每月的图像处理额度，<a target="_blank" href="https://www.volcengine.com/products/imagex?utm_content=ImageX&utm_medium=i4vj9y&utm_source=u7g4zk&utm_term=ImageX-wanzi">立即注册</a>',
                ),
                array(
                    'id' => 'g_imgx',
                    'type' => 'switcher',
                    'title' => __('功能开关', 'wanzi'),
                    'subtitle' => __('开启/关闭 火山引擎 ImageX', 'wanzi'),
                    'text_on' => __('开启', 'wanzi'),
                    'text_off' => __('关闭', 'wanzi'),
                ),
                array(
                    'id' => 'g_imgx_region',
                    'type' => 'select',
                    'title' => __('加速地域', 'wanzi'),
                    'subtitle' => __('加速地域在创建服务的时候进行选择', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.volcengine.com/imagex/service_manage/">点击这里</a>查询加速地域', 'wanzi'),
                    'options' => array(
                        'cn-north-1' => __('国内', 'wanzi'),
                        'us-east-1' => __('美东', 'wanzi'),
                        'ap-singapore-1' => __('新加坡', 'wanzi')
                    ),
                ),
                array(
                    'id' => 'g_imgx_serviceid',
                    'type' => 'text',
                    'title' => __('服务 ID', 'wanzi'),
                    'subtitle' => __('服务 ID 可在图片服务管理中查看', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.volcengine.com/imagex/service_manage/">点击这里</a>查询服务 ID', 'wanzi'),
                ),
                array(
                    'id' => 'g_imgx_url',
                    'type' => 'text',
                    'title' => __('加速域名', 'wanzi'),
                    'subtitle' => __('域名结尾不要添加 /', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.volcengine.com/imagex/service_manage/">点击这里</a>查询加速域名', 'wanzi'),
                ),
                array(
                    'id' => 'g_imgx_tmp',
                    'type' => 'text',
                    'title' => __('处理模板', 'wanzi'),
                    'subtitle' => __('处理模板可在图片处理配置中查看', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.volcengine.com/imagex/image_template/">点击这里</a>查询处理模板', 'wanzi'),
                ),
                array(
                    'id' => 'g_imgx_accesskey',
                    'type' => 'text',
                    'title' => __('AccessKey', 'wanzi'),
                    'subtitle' => __('出于安全考虑，建议周期性地更换密钥', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.volcengine.com/iam/keymanage/">点击这里</a>查询 AccessKey', 'wanzi'),
                ),
                array(
                    'id' => 'g_imgx_secretkey',
                    'type' => 'text',
                    'attributes' => array(
                        'type' => 'password',
                    ),
                    'title' => __('SecretKey', 'wanzi'),
                    'subtitle' => __('出于安全考虑，建议周期性地更换密钥', 'wanzi'),
                    'desc' => __('<a target="_blank" href="https://console.volcengine.com/iam/keymanage/">点击这里</a>查询 SecretKey', 'wanzi'),
                ),
            ),
            'default' => array(
                'g_imgx' => false,
                'g_imgx_region' => 'cn-north-1',
                "g_imgx_serviceid" => "",
                "g_imgx_url" => "",
                "g_imgx_tmp" => "",
                "g_imgx_accesskey" => "",
                "g_imgx_secretkey" => "",
            ),
        ),
    ),
));

CSF::createSection($prefix, array(
    'title' => __('收录配置', 'wanzi'),
    'icon' => 'fas fa-camera',
    'fields' => array(
        array(
            'id' => 'seo_shareimg',
            'type' => 'upload',
            'title' =>  __('分享图片', 'wanzi'),
            'library' => 'image',
            'preview' => true,
            'default' => get_template_directory_uri() . '/assets/img/default.jpg',
            'subtitle' => __('用于搜索引擎或社交工具抓取时使用', 'wanzi'),
        ),
        array(
            'id' => 'seo_keywords',
            'type' => 'text',
            'title' => __('关键词', 'wanzi'),
            'subtitle' =>  __('每个关键词之间需要用 , 分割', 'wanzi'),
        ),
        array(
            'id' => 'seo_description',
            'type' => 'textarea',
            'title' => __('站点描述', 'wanzi'),
            'subtitle' =>  __('网站首页的描述信息', 'wanzi'),
        ),
        array(
            'id' => 'seo_statistical',
            'title' => __('统计代码', 'wanzi'),
            'subtitle' => __('<span style="color:red">输入代码时请注意辨别代码安全性</span>', 'wanzi'),
            'type' => 'code_editor',
            'settings' => array(
                'theme' => 'default',
                'mode' => 'htmlmixed',
            ),
            'sanitize' => false,
            'default' => '<script></script>',
        ),
        array(
            'id' => 'seo_robots_fieldset',
            'type' => 'fieldset',
            'fields' => array(
                array(
                    'type' => 'subheading',
                    'content' => __('robots.txt 配置', 'wanzi'),
                ),
                array(
                    'type' => 'content',
                    'content' => '<ul> <li>' . __('- 需要 ', 'wanzi') . '<a href="' . admin_url('options-reading.php') . '" target="_blank">' . __('设置-阅读-对搜索引擎的可见性', 'wanzi') . '</a>' . __(' 是开启的状态，以下配置才会生效', 'wanzi') . '</li><li>' . __('- 如果网站根目录下已经有 robots.txt 文件，下面的配置不会生效', 'wanzi') . '</li><li>' . __('- 点击 ', 'wanzi') . '<a href="' . home_url() . '/robots.txt" target="_blank">robots.txt</a>' . __(' 查看配置是否生效，如果网站开启了 CDN，可能需要刷新缓存才会生效', 'wanzi') . '</li></ul>',
                ),
                array(
                    'id' => 'seo_robots',
                    'type' => 'textarea',
                ),
            ),
            'default' => array(
                'seo_robots' => getrobots(),
            ),
        ),
    ),
));

CSF::createSection($prefix, array(
    'title' =>  __('邮件配置', 'wanzi'),
    'icon' => 'fas fa-envelope',
    'fields' => array(
        array(
            'id' => 'm_smtp',
            'type' => 'switcher',
            'title' => __('SMTP 服务', 'wanzi'),
            'subtitle' => __('启用/禁用 SMTP 服务', 'wanzi'),
            'default' => false,
        ),
        array(
            'id' => 'm_host',
            'type' => 'text',
            'title' => __('邮件服务器', 'wanzi'),
            'subtitle' => __('填写发件服务器地址', 'wanzi'),
            'placeholder' => __('smtp.example.com', 'wanzi'),
        ),
        array(
            'id' => 'm_port',
            'type' => 'text',
            'title' => __('服务器端口', 'wanzi'),
            'subtitle' => __('填写发件服务器端口', 'wanzi'),
            'placeholder' => __('465', 'wanzi'),
        ),
        array(
            'id' => 'm_sec',
            'type' => 'text',
            'title' => __('授权方式', 'wanzi'),
            'subtitle' => __('填写登录鉴权的方式', 'wanzi'),
            'placeholder' => __('ssl', 'wanzi'),
        ),
        array(
            'id' => 'm_username',
            'type' => 'text',
            'title' => __('邮箱帐号', 'wanzi'),
            'subtitle' => __('填写邮箱账号', 'wanzi'),
            'placeholder' => __('user@example.com', 'wanzi'),
        ),
        array(
            'id' => 'm_passwd',
            'type' => 'text',
            'title' => __('邮箱密码', 'wanzi'),
            'subtitle' => __('填写邮箱密码', 'wanzi'),
            'attributes' => array(
                'type' => 'password',
            ),
        ),
        array(
            'id'      => 'enable_post_notification',
            'type'    => 'switcher',
            'title'   => __('发布文章时通知订阅者', 'wanzi'),
            'label'   => __('启用此功能后，每当有新文章发布，系统将自动向所有订阅者发送邮件。', 'wanzi'),
            'default' => true,
        ),
    ),
));

CSF::createSection($prefix, array(
    'id' => 'footer_fields',
    'title' => __('页脚配置', 'wanzi'),
    'icon' => 'far fa-window-maximize',
));



CSF::createSection($prefix, array(
    'parent' => 'footer_fields',
    'title' => __('备案信息', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'id' => 's_icp',
            'type' => 'text',
            'title' => __('工信部备案信息', 'wanzi'),
            'subtitle' => __('由<a target="_blank" href="https://beian.miit.gov.cn/">工业和信息化部政务服务平台</a>提供', 'wanzi'),
            'placeholder' => __('闽ICP证XXXXXX号', 'wanzi'),
        ),
        array(
            'id' => 's_gov',
            'type' => 'text',
            'title' => __('公安备案信息', 'wanzi'),
            'subtitle' => __('由<a target="_blank" href="http://www.beian.gov.cn/">全国互联网安全管理服务平台</a>提供', 'wanzi'),
            'placeholder' => __('闽公网安备 XXXXXXXXXXXXX 号', 'wanzi'),
        ),
        array(
            'id' => 's_gov_link',
            'type' => 'text',
            'title' => __('公安备案链接', 'wanzi'),
            'subtitle' => __('由<a target="_blank" href="http://www.beian.gov.cn/">全国互联网安全管理服务平台</a>提供', 'wanzi'),
            'placeholder' => __('http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=xxxxx', 'wanzi'),
        ),
    ),
));

CSF::createSection($prefix, array(
    'parent' => 'footer_fields',
    'title' => __('版权信息', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'id' => 's_copyright',
            'type' => 'textarea',
            'title' => __('版权信息', 'wanzi'),
            'default' => 'COPYRIGHT © ' . wp_date('Y') . ' ' . get_bloginfo('name') . '. ALL RIGHTS RESERVED.',
        ),
    ),
));

CSF::createSection($prefix, array(
    'id' => 'ad_fields',
    'title' => __('广告配置', 'wanzi'),
    'icon' => 'fas fa-ad',
));

CSF::createSection($prefix, array(
    'parent' => 'ad_fields',
    'title' => __('文章广告', 'wanzi'),
    'icon' => 'fas fa-arrow-right',
    'fields' => array(
        array(
            'id' => 'single_ad_top_group',
            'type' => 'group',
            'title' => '文章顶部广告',
            'subtitle' => '点击添加广告，最多添加 3 个顶部广告',
            'min' => 1,
            'max' => 3,
            'fields' => array(
                array(
                    'id' => 'ad_id',
                    'type' => 'text',
                    'title' =>  __('唯一标识', 'wanzi'),
                    'subtitle' =>  __('仅用于识别广告内容，可以作为备注使用', 'wanzi'),
                ),
                array(
                    'id' => 'ad_img',
                    'type' => 'upload',
                    'title' => __('轮播图片', 'wanzi'),
                    'subtitle' =>  __('可以直接填写图片链接，也可以上传图片', 'wanzi'),
                    'library' => 'image',
                    'preview' => true,
                ),
                array(
                    'id' => 'ad_url',
                    'type' => 'text',
                    'title' =>  __('网址链接', 'wanzi'),
                    'subtitle' =>  __('需要填写完整的链接地址，包含协议头', 'wanzi'),
                ),
                array(
                    'id' => 'ad_switcher',
                    'type' => 'switcher',
                    'title' => __('功能开关', 'wanzi'),
                    'subtitle' => __('开启/关闭此条广告', 'wanzi'),
                    'text_on' => __('开启', 'wanzi'),
                    'text_off' => __('关闭', 'wanzi'),
                    'default' => true
                ),
            ),
        ),
        array(
            'id' => 'single_ad_bottom_group',
            'type' => 'group',
            'title' => '文章底部广告',
            'subtitle' => '点击添加广告，最多添加 3 个底部广告',
            'min' => 1,
            'max' => 3,
            'fields' => array(
                array(
                    'id' => 'ad_id',
                    'type' => 'text',
                    'title' =>  __('唯一标识', 'wanzi'),
                    'subtitle' =>  __('仅用于识别广告内容，可以作为备注使用', 'wanzi'),
                ),
                array(
                    'id' => 'ad_img',
                    'type' => 'upload',
                    'title' => __('轮播图片', 'wanzi'),
                    'subtitle' =>  __('可以直接填写图片链接，也可以上传图片', 'wanzi'),
                    'library' => 'image',
                    'preview' => true,
                ),
                array(
                    'id' => 'ad_url',
                    'type' => 'text',
                    'title' =>  __('网址链接', 'wanzi'),
                    'subtitle' =>  __('需要填写完整的链接地址，包含协议头', 'wanzi'),
                ),
                array(
                    'id' => 'ad_switcher',
                    'type' => 'switcher',
                    'title' => __('功能开关', 'wanzi'),
                    'subtitle' => __('开启/关闭此条广告', 'wanzi'),
                    'text_on' => __('开启', 'wanzi'),
                    'text_off' => __('关闭', 'wanzi'),
                    'default' => true
                ),
            ),
        ),
    ),
));

CSF::createSection($prefix, array(
    'title' => __('备份恢复', 'wanzi'),
    'icon' => 'fas fa-undo',
    'fields' => array(
        array(
            'type' => 'backup',
        ),
    ),
));

CSF::createSection($prefix, array(
    'title' => __('关于主题', 'wanzi'),
    'icon' => 'fas fa-question-circle',
    'fields' => array(
        array(
            'type' => 'subheading',
            'content' => __('基础信息', 'wanzi'),
        ),
        array(
            'type' => 'content',
            'content' => '<ul style="margin: 0 auto;"> <li>' . __('PHP 版本：', 'wanzi') . PHP_VERSION . '</li> <li>' . __('wanzi 版本：', 'wanzi') . THEME_VERSION . '</li> <li>' . __('WordPress 版本：', 'wanzi') . $wp_version . '</li> <li>' . __('User Agent 信息：', 'wanzi') . '<span id="user-agent"></span></li> </ul><script>document.getElementById("user-agent").textContent = navigator.userAgent;</script>',
        ),
    ),
));
